package com.pingan.agentbank.aaos.service;
/**
 * Title:
 * Description:Generate by isql(lianght).
 * @Copyright: Copyright (c) 2008
 * @Company: CORSWORK
 * @author: lianght
 * @version: 1.0.0
 * @time: Fri Nov 23 10:29:17 CST 2018
 */

import com.pingan.agentbank.aaos.dao.ApproLineDao;
import com.pingan.agentbank.aaos.pojo.ApproLineInfo;

import java.util.*;

import com.pingan.vframe.db.DBIterator;
import com.pingan.vframe.lang.*;

/**
 * Class description:ApproLineDaoService
 * 
 * @author 
 */
public class ApproLineDaoService {
	@Inject
	ApproLineDao dao;

	public ApproLineInfo getApproLineInfoByKey(int id) {
		return dao.get(id);
	}

	public int saveOneApproLineInfo(ApproLineInfo info) {
		boolean hasInDB = dao.get(info) != null;
		int count = 0;
		if(hasInDB) {
			count = dao.update(info);
		} else {
			count = dao.insert(info);
		}
		return count;
	}

	public int countAllApproLineInfo() {
		return dao.countAll();
	}

	public List<ApproLineInfo> pageApproLineInfos(long fileId,int offset, int size) {
		return dao.pageApproLineInfos(fileId,offset, size);
	}

	public int deleteOneApproLineInfo(int id) {
		return dao.delete(id);
	}

	public int deleteApproLineInfos(String pks) {
		int count = 0;
		if (pks != null) {
			String[] arr_codes = pks.split(",");
			for (String code:arr_codes) {
				count += dao.delete(code);
			}
		}
		return count;
	}

	//user-defined

	//query
	public DBIterator<ApproLineInfo> queryByFileId(long fileId){
		return dao.queryByFileIdForUpdate(fileId);
	}

	public ApproLineInfo queryById(long id){
		return dao.get(id);
	}

	//delete
	public int deleteByFileId(long fileId){
		return dao.deleteByFileId(fileId);
	}

}
